using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableUnionTechDao:DaoBase<TableUnionTech>
    {
        public override void AddPrimaryIndex(TableUnionTech model)
        {
            cachePrimary[model.techLevel.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableUnionTech.txt";
        }

        protected override TableUnionTech ParseRowData(string[] rowData)
        {
            TableUnionTech data = new TableUnionTech();

            if (string.IsNullOrEmpty(rowData[0]))
            {
                data.techLevel = 0;
            }
            else
            {
                data.techLevel = int.Parse(rowData[0]);
            }
			data.type = rowData [1];
			data.prop = rowData [2];

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.UnionBadge = 0;
            }
            else
            {
                data.UnionBadge = int.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.UnionCoin = 0;
            }
            else
            {
                data.UnionCoin = int.Parse(rowData[4]);
            }
			data.name = rowData [5];
			data.icon = rowData [6];

            return data;
        }



        public override void AddTwoIndex(TableUnionTech model)
        {
            string key = GetUnionKey(model.techLevel.ToString(),model.type.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TableUnionTech>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
